import type { App } from 'vue'
import { createPinia } from 'pinia'

const store = createPinia()

/**
 * 初始化store
 * @param app
 */
export const setupStore = async (app: App) => {
  app.use(store)
}

/**
 * 重置所有store
 */
export const resetAllStores = () => {
  const allStores = (store as any)._s
  for (const [_key, store] of allStores) {
    store.$reset()
  }
}

export { store }
